package com.hdyg.sixg.mvp.presenter;

import com.hdyg.sixg.entry.LoginBean;
import com.hdyg.sixg.entry.VersionBean;
import com.hdyg.sixg.httpUtil.HttpCallback;
import com.hdyg.sixg.mvp.Contrant.CLogin;
import com.hdyg.sixg.mvp.base.BasePresenter;
import com.hdyg.sixg.util.ToastUtil;
import java.util.Map;

/**
 * @author CZB
 * @describe 登录
 * @time 2019/4/10 9:54
 */
public class PLogin extends BasePresenter implements CLogin.IPLogin {

    private CLogin.IVLogin mView;

    public PLogin(CLogin.IVLogin mView) {
        this.mView = mView;
    }

    @Override
    public void pGetLogin(String path, Map<String, String> params) {

        mModel.post(path, params, new HttpCallback<LoginBean>(true) {
            @Override
            public void onSuccess(LoginBean loginBean) {
                mView.vGetLoginSuccess(loginBean);
            }

            @Override
            public void onFail(String code, String error) {
                ToastUtil.show(error);
            }
        });
    }

    @Override
    public void pGetVersion(String path, Map<String, String> params) {
        mModel.post(path, params, new HttpCallback<VersionBean>(false) {
            @Override
            public void onSuccess(VersionBean dataBean) {
                mView.vGetVersionSuccess(dataBean);
            }

            @Override
            public void onFail(String code, String error) {
                ToastUtil.show(error);
            }
        });
    }
}
